package com.cx.purchase.spare.mapper;

import com.cx.purchase.spare.model.*;
import org.apache.ibatis.annotations.*;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Mapper
public interface SpareMapper {


    List<SpareVo> queryData(SpareSelectVo spareSelectVo);

    int queryCount(SpareSelectVo spareSelectVo);

    @Select("SELECT * FROM tax")
    List<TaxTypeSelectVo> querytaxtypeId();
    @Select("SELECT f.legalPlantCode FROM \n" +
            "factory f LEFT JOIN legalperson l ON f.legalPersonCode = l.legalPersonCode"
            )
    List<String> queryPlantCode(SelectByLegalPersonCode selectByLegalPersonCode);
    @Select("SELECT p.priceTypeName FROM price p LEFT JOIN material_price m ON m.priceType = p.priceType")
    List<String> queryPriceType(List<String> priceType);

    @Select("select priceTypeName label, priceType value from price")
    ArrayList<status> queryCurrencyCode();

    @Select("SELECT status VALUE, statusName label from material_price ")
    ArrayList<status> queryStatus();

    @Select("SELECT currencyCode value,currencyCodeName lable from material_price ")
    ArrayList<status> queryCurrCode();


    List<SpareLiSelectVo> queryMeData(SpareLiSelectVo spareLiSelectVo);

    int queryMeCount(SpareLiSelectVo spareLiSelectVo);
    @Insert("insert into material_price(priceType,materialCode,currencyCode,price,startTime,endTime,remark,taxType,status,createName,createTime,updateName,updateTime" +
            ")values (#{priceType},#{materialCode},#{currencyCode},#{price},#{startTime},#{endTime},#{remark},#{taxType},1,#{createName},#{createTime},#{updateName},#{updateTime})")
    void add(SpareVo spareVo);

    @Update("update material_price set status = #{status} where id = #{id} ")
    void updateStatus(SpareVo spareVo);
    @Update("update material_price set remark=#{remark},endTime=#{endTime} where id=#{id}")
    void update(SpareVo spareVo);

    @Update("update material_price set starTime = #{param1} where id = #{param2}")
    void update1(Date date, Integer id);

    @Delete("delete from material_price where id = #{id}")
    void delete1(Integer id);

    @Update("update material_price set starTime = #{param1} where id = #{param2}")
    void update2(Date date, Integer id);

    SpareVo querySpare(SpareAdd spareAdd);

    @Select("select materialCode from material ")
    List<String> queryCode();
    @Select("select materialName from material ")
    List<String> queryName();

    void addAll(SpareAdd sussceList);
}
